<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="李愧愧">
    <title></title>
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            background-color: burlywood;
        }

        .clearfix::after {
            content: "";
            display: block;
            clear: both;
        }

        ul {
            float: left;
        }

        a {
            display: inline-block;
            text-decoration: none;
            color: white;
            text-align: center;
            line-height: 49px;
            color: white;
            width: 100px;
            height: 49px;
            background-color: black;
        }

        .content {
            width: 500px;
            border: 1px solid black;
        }

        .ok {
            width: 100%;
            height: 50px;
            border-bottom: 1px solid black;
            background-color: black;
            position: relative;
        }

        .nav {
            float: left;
        }

        .box {
            width: 500px;
            color: black;
            display: none;
            /* float: left; */
            position: absolute;
            top: 50px;
            left: 0px;
            background-color: lightblue;
            border: 1px solid black;
        }

        .aa {
            background-color: lightgray;
        }

        .box1 {
            display: block;
        }
    </style>
</head>

<body>
    <div class="content clearfix">
        <div class="ok clearfix">
            <div class="nav">
                <a href="" class="aa">第一节</a>
                <div class="box box1">
                    <ul>
                        <li>第一节</li>
                        <li>第一节</li>
                        <li>第一节</li>
                        <li>第一节</li>
                        <li>第一节</li>
                        <li>第一节</li>
                    </ul>
                </div>
            </div>
            <div class="nav">
                <a href="">第二节</a>
                <div class="box">
                    <ul>
                        <li>第二节</li>
                        <li>第二节</li>
                        <li>第二节</li>
                        <li>第二节</li>
                        <li>第二节</li>
                        <li>第二节</li>
                        <li>第二节</li>
                    </ul>
                </div>
            </div>
            <div class="nav">
                <a href="">第三节</a>
                <div class="box">
                    <ul>
                        <li>第三节</li>
                        <li>第三节</li>
                        <li>第三节</li>
                        <li>第三节</li>
                        <li>第三节</li>
                        <li>第三节</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <script>
        var a = document.querySelectorAll('a');
        var box = document.querySelectorAll('.box');
        for (var i = 0; i < a.length; i++) {
            a[i].index = i;
            box[i].index = i;
            console.dir(a[i]);
            console.dir(box[i]);

            a[i].onmouseover=function (ev){
                console.dir(ev);

                for(var j = 0; j < a.length; j++){
                    a[j].classList.remove('aa');
                    box[j].classList.remove('box1')
                }
                a[this.index].classList.add('aa');
                box[this.index].classList.add('box1')
            }
        }
    </script>
</body>

</html>